package com.guqiao.library.utils;

import android.content.Context;
import android.text.TextUtils;
import android.widget.Toast;

/**
 * @author jiangyao
 * @desc Toast工具类
 */
public class ToastUtils {

    private static Toast toast;

    public static void showShortToast(Context context, String message) {
        if (!TextUtils.isEmpty(message)) {
            context = context.getApplicationContext();
            if (toast == null) {
                toast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
            } else {
                toast.setText(message);
            }
            toast.show();
        }
    }

    public static void showLongToast(Context context, String message) {
        context = context.getApplicationContext();
        if (toast == null) {
            toast = Toast.makeText(context, message, Toast.LENGTH_LONG);
        } else {
            toast.setText(message);
        }
        toast.show();
    }

    public static void show(Context context, String message, int time) {
        context = context.getApplicationContext();
        if (toast == null) {
            toast = Toast.makeText(context, message, time);
        } else {
            toast.setText(message);
        }
        toast.show();
    }
}
